import { createRouter, createWebHistory } from "vue-router";
import App from "../App.vue";
import myComponent from "../views/myComponent/index.vue";
import login from "../views/login/index.vue";
import test from "../views/test/test.vue";

/** 路由白名单 */
const whiteList = ["/login"];

const routes = [
  {
    path: "/home",
    name: "App",
    component: App,
  },
  {
    path: "/myComponent",
    name: "myComponent",
    component: myComponent,
  },
  {
    path: "/login",
    name: "login",
    component: login,
  },
  {
    path: "/test",
    name: "test",
    component: test,
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

//路由守卫
// router.beforeEach((to, from, next) => {
//   const isAuthenticated = "a"; /* 检查用户是否已登录 */
//   if (to.name !== "Login" && !isAuthenticated) {
//     next({ name: "Login" });
//   } else {
//     next();
//   }
// });

export default router;
